<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动定位</title>
  <style>
    /*是否选中了外层的div？*/
    body>div{
      width: 180px;
      border: 1px solid red;
    /*  解决高度自识别为 0  的问题*/
      overflow: auto;/*hidden*/
    }
    #d1{
      width: 50px;
      height: 50px;
      background-color: green;
      /*向右浮动*/
      float: right;
    }
    #d2{
      width: 50px;
      height: 59px;
      background-color: deeppink;
      /*向右浮动*/
      float: right;
    }
    #d3{
      width: 50px;
      height: 50px;
      background-color: yellow;
      /*向右浮动*/
      float: right;
    }

    #d4{
      width: 50px;
      height: 50px;
      background-color: blue;
      /*向右浮动*/
      float: right;
    }

  </style>

</head>
<body>

  <div>
    <div id="d1"></div>
    <div id="d2"></div>
    <div id="d3"></div>
    <div id="d4"></div>
  </div>

</body>
</html>